﻿// 1.1.3.10. Write a program that extract the four digits of a number in variables and do some actions with the digits.

using System;

class DigitsActions
{
    static void Main()
    {
        while (true)
        {
            Console.Write("Please enter a 4 digit integer number: ");
            short input = short.Parse(Console.ReadLine());
            short d = (short)(input % 10);  // or (input / 1) % 10
            short c = (short)(((input % 100) - d) / 10);    // or = (input / 10) % 10    
            short b = (short)(((input % 1000) - c) / 100);  // or = (input / 100) % 10   
            short a = (short)(((input % 10000) - b) / 1000);    // or = (input / 1000) % 10
            Console.WriteLine(a + b + c + d);   // addition of the digits
            Console.WriteLine(d.ToString() + c + b + a);    // using the digits as separate stings
            Console.WriteLine(d + c + b + a.ToString());    // close to a bug - the first three are addition and the fourth is a separate string
        }
        
    }
}
